//
//  TopicCell.m
//  Leisure
//
//  Created by xalo on 16/6/30.
//  Copyright © 2016年 蓝鸥科技有限公司西安分公司. All rights reserved.
//

#import "TopicCell.h"

@interface TopicCell ()
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UILabel *content;
@property (weak, nonatomic) IBOutlet UILabel *comment;
@property (weak, nonatomic) IBOutlet UILabel *addtime;

@end

@implementation TopicCell


-(void)setCellWithModel:(TopicModel *)model{
    self.title.text = model.title;
    self.title.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:model.coverimg] placeholderImage:[UIImage imageNamed:@"2-3.jpg"]];
    self.content.text = model.content;
    
    NSMutableParagraphStyle *style = [NSMutableParagraphStyle defaultParagraphStyle].mutableCopy;
    style.lineSpacing = 5;
    NSAttributedString *attribute = [[NSAttributedString alloc]initWithString:self.content.text attributes:@{NSParagraphStyleAttributeName:style}];
    self.content.attributedText = attribute;
    
    self.addtime.text = model.addtime_f;
    self.comment.text = model.comment.description;
    
}

-(CGFloat)returnCellHeight{
    
    CGFloat labelHeight = [SizeToFitTool fixHeightToLabelText:self.title.text font:[UIFont systemFontOfSize:21] label:self.title.frame.size.width];
    CGFloat contentHeight = [SizeToFitTool fixHeightToLabelText:self.content.text font:[UIFont systemFontOfSize:19] label:self.content.frame.size.width];
    CGFloat imageViewHeight = [SizeToFitTool fixHeightWithImageView:self.leftImageView imageWidth:self.leftImageView.frame.size.width];
    
    
    return labelHeight +contentHeight + imageViewHeight + 10;
    
    
}



- (void)awakeFromNib {
    // Initialization code
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
